package kayao.client.input;

import java.io.IOException;

import kayao.client.R;
import kayao.client.data.SharedMemory;
import android.content.Context;
import android.media.MediaPlayer;


public class Sound {

	//	private MediaPlayer mPlayer = new MediaPlayer();
	private MediaPlayer mPlayerScrewed;
	private MediaPlayer mPlayerRock;
	private boolean mDataSet;
	private boolean mPrepared;
	private boolean mStopped;
	private boolean mReady = false;

	public Sound(){
		Context c= SharedMemory.getInstance().getContext();
		mPlayerScrewed = MediaPlayer.create(c, R.raw.screwed);
		mPlayerRock = MediaPlayer.create(c, R.raw.werock);
		mPlayerScrewed.setVolume(5, 5);
		mPlayerRock.setVolume(5, 5);
		System.out.println("Sound init");
	}
	
	public void playScrewed(){

		if(mPlayerScrewed.isPlaying()){
			System.out.println("Sound is playing");
			return;
		}

		mPlayerScrewed.stop();
		try {
			mPlayerScrewed.prepare();
			mPlayerScrewed.start();
			System.out.println("Played Sound");
		} catch (IllegalStateException e) {
			System.out.println("Sound init ERROR1");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("Sound init ERROR2");
			e.printStackTrace();
		}		
	}
	
	public void playRock(){

		if(mPlayerRock.isPlaying()){
			System.out.println("Sound is playing2");
			return;
		}

		mPlayerRock.stop();
		try {
			mPlayerRock.prepare();
			mPlayerRock.start();
			System.out.println("Played Sound2");
		} catch (IllegalStateException e) {
			System.out.println("Sound init ERROR12");
			e.printStackTrace();
		} catch (IOException e) {
			System.out.println("Sound init ERROR22");
			e.printStackTrace();
		}		
	}

}
